package Com.javaserver.servlet;

import Com.javaserver.bean.departmentinquire;
import Com.javaserver.dao.departmentserver;
import Com.javaserver.utils.DB;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet("/queryALl")
public class ShowDeptServlet extends HttpServlet {

   departmentserver depar=new departmentserver();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String page=req.getParameter("page");
        if(page==null){
            page="1";
        }
        List<Map<String, Object>> list = DB.executeQuery("select count(*) count from department");
        req.getSession().setAttribute("userLen", list.get(0).get("count"));
        req.getSession().setAttribute("deptList", depar.queryALl(Integer.parseInt(page)));
        req.getSession().setAttribute("nav", "部门管理");
        resp.sendRedirect(req.getContextPath() + "/Department.jsp");
    }
}
